package com.resume.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.resume.constant.GlobalConst;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

import com.resume.mapper.XueLiMapper;
import com.resume.domain.XueLi;
import com.resume.service.XueLiService;


@Service
public class XueLiServiceImpl extends ServiceImpl<XueLiMapper, XueLi> implements XueLiService {

    @Override
    public List<XueLi> listAllUsableXueLi() {
        QueryWrapper<XueLi> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("id", "name", "info")
                .eq("status", GlobalConst.Common.STATUS_ENABLE);// 1 表示显示

        List<XueLi> xueLiList = baseMapper.selectList(queryWrapper);
        return xueLiList;
    }

    @Override
    public boolean modifyXueLiStatus(Integer id, Integer status) {
        XueLi xueLi = XueLi.builder()
                .id(id)
                .status(status)
                .build();
        int res = baseMapper.updateById(xueLi);
        return res == 1 ? true : false;
    }

    @Override
    public boolean modify(XueLi xueLi) {
        QueryWrapper<XueLi> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id",xueLi.getId());
        int updateRes = baseMapper.update(xueLi, queryWrapper);
        return updateRes == 1 ? true : false;
    }
}
